﻿
@mweditor.PluginScript()
export default class IconEditor extends mweditor.PluginEditor {

    onStart() {

    }

    onDestroy() {
        super.onDestroy()
    }

    // @mweditor.MenuItem("重读")
    // private serach() {
    //     let pb = mweditor.findEditorSystem(mweditor.PluginBrowser)
    //     pb.getAllLoadedPlugins().forEach((val) => {
    //         pb.reloadPlugin(val)
    //     })
    // }
    private static iconView = null;
    @mweditor.MenuItem("Icon工具")
    static async openWindow() {
        //重读一次，关闭后没走onDestroy
        let pb = mweditor.findEditorSystem(mweditor.PluginBrowser)
        pb.getAllLoadedPlugins().forEach((val) => {
            if (val.pluginName == "Icon工具")
                pb.reloadPlugin(val)
        })

        let EditorCommonUtility = mweditor.findEditorSystem(mweditor.Window);
        if (EditorCommonUtility.hasWinowActive(this.iconView)) {
            EditorCommonUtility.focusWindow(this.iconView);
        }
        else {
            this.iconView = EditorCommonUtility.showCustomGameUIWindow('IconTool/Editor/UI/ToolUI.ui', new Vector2(320, 600), "Icon工具", mweditor.WindowShowType.Top);
        }
        // if (!this.iconView)
        //     this.iconView = mweditor.Window.createUIWindow('IconTool/Editor/UI/ToolUI.ui', new Vector2(320, 600), "Icon工具", mweditor.WindowShowType.Top);
        // this.iconView?.focus();
    }

}
